package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2018/12/18 19:39
 * @description
 */
public class Code171 {
    public static void main(String[] args) {
        new Code171().titleToNumber("AA");
    }

    public int titleToNumber(String s) {
        int sum = 0;
        int length = s.length();
        for (char c : s.toCharArray()) {
            sum += getNumb(c - 64, --length);
        }
        return sum;
    }

    private int getNumb(int n1, int n) {
        return (int)(Math.pow(26, n) * n1);
    }
}
